package cn.tedu.hospital.doctor.controller;

import cn.tedu.hospital.base.response.JsonResult;
import cn.tedu.hospital.doctor.pojo.dto.DoctorDto;
import cn.tedu.hospital.doctor.pojo.vo.DoctorVo;
import cn.tedu.hospital.doctor.service.DoctorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/doctor")
public class DoctorController {
    @Autowired
    DoctorService doctorService;

    @GetMapping("select")
    public JsonResult select(DoctorDto doctorDto) {
        log.debug("查询用户doctorDto={}",doctorDto);
        List<DoctorVo> list = doctorService.select(doctorDto);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult save(DoctorDto doctorDto) {
        log.debug("保存用户doctorDto={}",doctorDto);
        doctorService.save(doctorDto);
        return JsonResult.ok();
    }
    @PostMapping("delete/{doctorId}")
    public JsonResult delete(@PathVariable Long doctorId) {
        log.debug("删除用户doctorId={}",doctorId);
        doctorService.delete(doctorId);
        return JsonResult.ok();
    }
}
